package advance.x000.acw_93;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {

    public static List<Integer> subset;
    public static List<List<Integer>> ans;
    public static int[] nums;
    public static int n;
    public static int m;

    // 递归实现组合型枚举
    public static void main(String[] args) {
        Main solution = new Main();
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();
        //求1——n 子集的个数
        nums = new int[n];
        subset = new ArrayList<>();
        ans = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            nums[i] = i + 1;
        }
        solution.clac(0);

        // 在这里是一样长
        Collections.sort(ans, (e1, e2) -> {
            int len=e1.size();
            int i=0;
            while(i<len){
                if(e1.get(i)!= e2.get(i)){
                    return e1.get(i) -e2.get(i);
                }else{
                    i++;
                }
            }
            return  0;
        });

        for (List<Integer> list : ans) {
            Collections.sort(list);
            for (Integer val : list) {
                System.out.print(val + " ");
            }
            System.out.println();
        }
    }

    private void clac(int cur) {
        if (subset.size() > m || subset.size() + (n - cur) < m) {
            return;
        }
        // 留下整好m个数的分支
        if (cur == nums.length) {
            ans.add(new ArrayList<>(subset));
            return;
        }
        // 两种情况
        //当前值不加
        clac(cur + 1);

        //加当前值
        subset.add(nums[cur]);
        clac(cur + 1);
        subset.remove(subset.size() - 1);
    }

}
